﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MX.Core.ORM
{
    public class PagerResult<T>
    {
        public int PageSize { get; set; }
        public int PageIndex { get; set; }
        public long RecordCount { get; set; }
        public int PageCount { get; set; }

        public List<T> List { get; set; }


        public PagerResult<F> Copy<F>(Func<T, F> fun)
        {
            var list = List.Select(p => fun(p)).ToList();
            return new PagerResult<F>()
            {
                List = list,
                PageCount = PageCount,
                PageIndex = PageIndex,
                PageSize = PageSize,
                RecordCount = RecordCount
            };
        }

        public PagerResult<F> Copy<F>(Func<dynamic, F> fun)
        {
            var list = List.Select(p => fun(p)).ToList();
            return new PagerResult<F>()
            {
                List = list,
                PageCount = PageCount,
                PageIndex = PageIndex,
                PageSize = PageSize,
                RecordCount = RecordCount
            };
        }

     
    }
}
